let OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')
let UglifyJsPlugin = require('uglifyjs-webpack-plugin')

const splitChunks = {
    cacheGroups: {
        default: {
            priority: -20,
            reuseExistingChunk: true,
        },
        vendors: {
            test: /node_modules/,
            name: 'vendor',
            chunks: 'initial',
            priority: 10, // 优先
            enforce: true
        },
        commons: {
            name: 'commons',
            chunks: 'initial',
            minChunks: 1,
            minSize: 0
        }
    }
}
const minimizer = [
    new UglifyJsPlugin({
        uglifyOptions: {
            output: {
                comments: false
            }
        },
        extractComments: true,
        cache: true,
        parallel: true,
        sourceMap: false // set to true if you want JS source maps

    }),
    new OptimizeCSSAssetsPlugin({})
]

module.exports = (ispod, target) => {
    return {
        splitChunks: splitChunks
    }
}
